import { modelConfigApi } from '@/api'
import { useDefineLoading } from '@/hooks'
import type { IndicatorInfo } from '@/types'

export function useIndicatorTable() {
  const { withLoading, vLoading } = useDefineLoading()
  const tableData = ref<IndicatorInfo[]>([])

  const getTableData = async (
    modelType: string = '1',
    pointId: number = 0,
  ) => {
    try {
      tableData.value = []
      const { data } = await withLoading(
        modelConfigApi.getMonitorConfig,
      )(modelType, pointId)
      tableData.value = data || []
    }
    catch (e) {}
  }

  return {
    tableData,
    vLoading,
    /** 查询指标列表数据 */
    getTableData,
  }
}
